package VN.EDU.IMIC.PROJECTLEADER.NGUYENVANDOAN.ARRAYEXCERCISES.EX06;

import java.util.Scanner;

public class VIEWS {
    public static void main(String[] args) {
        System.out.print("\n+ Enter the number of students = ");
        int n = 0;
        Scanner input = new Scanner(System.in);
        n = input.nextInt();

        // 2. Khởi tạo mảng đối tượng sinh viên
        // double[] myArr = new double[n];
        STUDENT_ENTITY[] arrStudent = new STUDENT_ENTITY[n];

        // 3.Khoi tao doi tuong sinh vien
        STUDENT_ENTITY objStudent = null;

        for (int i = 0; i < arrStudent.length; i++) {
            System.out.print("\n+ Enter students name = ");
            input = new Scanner(System.in);
            String name = input.nextLine();
            System.out.print("\n+ Enter their scores = ");
            double scores = input.nextDouble();
            objStudent = new STUDENT_ENTITY(name, scores);
            arrStudent[i] = objStudent;
        }

        // Sort
        /* objStudent.StudentSort(arrStudent); */
        // Ủy quyền thực thi sắp xếp cho Controllers
        CONTROLLERS objController = new CONTROLLERS();
        // Ctrl + Shift + b : Đánh dấu điểm dừng khi cần debug
        STUDENT_ENTITY[] arrGetStudent = objController.SelectionSort(arrStudent);

        // Prints
        PrintArray(arrGetStudent);
    }

    static private void PrintArray(STUDENT_ENTITY[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print("\n + Name of Students[" + i + "]" + arr[i].getStudentName());
            System.out.print("\n + Scores of Students[" + i + "]" + arr[i].getScores());
        }
    }
}
